**************************
** Open-Ended Responses **
***** Data Analysis ******
**************************

*Last updated: June 1, 2024
*Last updated by: Nazita Lajevardi
*Tested on Stata 16

clear all

*** Change working directory
cd "" /*insert your own file path*/

** Nazita working directory:
*cd "/Users/nazita/Dropbox/Personal/MSU/Projects/Debbi Naz Per Conjoint/PS Submission/Replication Files/Text Analysis in Stata/"

use "conjointdata_final.dta", clear
	
*** Install packages
ssc install estout
ssc install latab	
	
*******************
** In Text Table **
*******************

*Table 1
 
eststo clear
eststo:reg jillian_positive anxiety_cc anxiety_immigration anxiety_employment
eststo:reg jillian_positive anxiety_cc  anxiety_immigration anxiety_employment female age democrat independent ideology income educ black latino asian immigrant otherrace
eststo:reg jillian_negative anxiety_cc anxiety_immigration anxiety_employment  
eststo:reg jillian_negative anxiety_cc anxiety_immigration anxiety_employment  female age democrat independent ideology income educ black latino asian immigrant otherrace
esttab, se ar2  b(3) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  drop (female age democrat independent ideology income educ black latino asian immigrant otherrace )
esttab using table1.tex, se ar2  b(3) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label replace drop ( female age democrat independent ideology income educ black latino asian immigrant otherrace)


*********************
** Appendix Tables **
*********************

*Table A1: Summary Statistics 
latabstat white nonwhite  immigrant native Anxiety_cc_high  Anxiety_cc_low high_pp_cc low_pp_cc male female age age_young age_older democrat republican independent ideology income low_income high_income educ low_education high_education biden2020 trump2020 , stat(mean sd min max count)  col(stat) format(%9.2g)  long 	 


*Table A4: Open-Ended Percentages
latabstat jillian_positive jillian_negative jillian_mentions_imm jillian_mentions_personalbeliefs jillian_sitchcontrol jillian_sitchcontrol_naturaldis jillian_mentions_age jillian_mentions_lang jillian_mentions_ed jillian_mentions_kids jillian_mentions_region jillian_mentions_gender jillian_mentions_religion, stat(mean sd min max count)  col(stat)  long 	 

*Table A5
 eststo clear
eststo:reg jillian_positive anxiety_cc anxiety_immigration anxiety_employment
eststo:reg jillian_positive anxiety_cc  anxiety_immigration anxiety_employment female age democrat independent ideology income educ black latino asian immigrant otherrace
eststo:reg jillian_negative anxiety_cc anxiety_immigration anxiety_employment  
eststo:reg jillian_negative anxiety_cc anxiety_immigration anxiety_employment  female age democrat independent ideology income educ black latino asian immigrant otherrace
esttab, se ar2  b(3) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  
esttab using tablea5.tex, se ar2  b(3) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) label replace 
